import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:hook_up_rent/pages/errPage/not_found.dart';
import 'package:hook_up_rent/pages/login/login.dart';
import 'package:hook_up_rent/pages/register/register.dart';
import 'package:hook_up_rent/pages/room_add/room_add.dart';
import 'package:hook_up_rent/pages/room_detail/room_detail.dart';
import 'package:hook_up_rent/pages/room_manage/room_mange.dart';
import 'package:hook_up_rent/pages/settings/settings.dart';
import 'package:hook_up_rent/widgets/bottom_tab.dart';

class MyRoutes {
  static String home = "/";
  static String login = "/login";
  static String roomDetail = "/room/:id";
  static String register = "/register";
  static String search = "/search";
  static String settings = "/settings";
  static String roomManage = "/roomManage";
  static String roomAdd = "/roomAdd";

  static Handler _homeHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return tabViewList[0];
  });
  static Handler _loginHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return LoginPage();
  });
  static Handler _registerHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RegisterPage();
  });
  static Handler _roomDetailHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RoomDetail(
      roomId: params['id'][0],
    );
  });
  static Handler _searchHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return tabViewList[1];
  });
  static Handler _notFoundHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return NotFoundPage();
  });
  static Handler _settingsHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return SettingsPage();
  });
  static Handler _roomManageHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RoomManagePage();
  });
  static Handler _roomAddHandler =
      Handler(handlerFunc: (BuildContext context, Map<String, dynamic> params) {
    return RoomAddPage();
  });

  static void configureRoutes(FluroRouter router) {
    router.define(home, handler: _homeHandler);
    router.define(login, handler: _loginHandler);
    router.define(roomDetail, handler: _roomDetailHandler);
    router.define(register, handler: _registerHandler);
    router.define(search, handler: _searchHandler);
    router.define(settings, handler: _settingsHandler);
    router.define(roomManage, handler: _roomManageHandler);
    router.define(roomAdd, handler: _roomAddHandler);
    router.notFoundHandler = _notFoundHandler;
  }
}
